package cn.zhou.basic.controller;

import cn.zhou.basic.dto.RegisterDto;
import cn.zhou.basic.service.IVerifyCodeService;
import cn.zhou.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifyCode")
public class VerifyCodeController {
//    get("/verifyCode/image/"+imageCodeKey)
    @Autowired
    private IVerifyCodeService verifyCodeService;
    @GetMapping("/image/{imageCodeKey}")
    public AjaxResult ImageCode(@PathVariable("imageCodeKey") String key){
        try {
            String base64Str=verifyCodeService.ImageCode(key);
            return new AjaxResult().setResultObj(base64Str);
        }catch( Exception e){
            e.printStackTrace();
            return new AjaxResult().setSuccess(false).setMessage("苏喂苏喂苏喂");
        }

    }
//    /verifyCode/smsCode
@PostMapping("/smsCode")
public AjaxResult SmsCode(@RequestBody RegisterDto dto ){
    try {
        verifyCodeService.SmsCode(dto);
        System.out.println("111111");
        return new AjaxResult();
    }catch( Exception e){
        e.printStackTrace();
        return new AjaxResult().setSuccess(false).setMessage("苏喂苏喂苏喂");
    }

}

}
